﻿package  {
	
	import DensityObjects.FlickingPanel;
	
	import FeedbackObjects.MessageBox;
	
	import TaskStructure.Task;
	import TaskStructure.XMLLoader;
	
	import flash.display.MovieClip;
	import flash.events.Event;
	
	[SWF(backgroundColor="#000000", width="840", height="400", frameRate="24")]
	
	public class Main extends MovieClip
	{
		private var xmlLoader:XMLLoader; // loads XML from current directory
		private var taskFlowXML:XML;
		private var task:Task;
		
		public function Main() 
		{
			this.graphics.drawRect (0, 0, this.stage.stageWidth, this.stage.stageHeight);
			xmlLoader = new XMLLoader();
			xmlLoader.addEventListener(Event.COMPLETE, handleFlowLoaderComplete);
			xmlLoader.init(String("densityFlashInputs.xml"));
			
		}
		private function handleFlowLoaderComplete (event:Event):void
		{
			xmlLoader.removeEventListener(Event.COMPLETE, handleFlowLoaderComplete);
			taskFlowXML = xmlLoader.xml;
			complete();
		}
		
		private function complete ():void
		{
			task = new Task(1, taskFlowXML);
			task.addEventListener(Event.COMPLETE, handleTaskComplete);
			this.addChild(task);
		}
		private function handleTaskComplete (event:Event):void
		{
			task.removeEventListener(Event.COMPLETE, handleTaskComplete);
		}
	}
}
